package com.djinfo.work.util.quartz;


import com.djinfo.work.service.DictService;
import com.djinfo.work.util.CacheUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;
import java.util.Date;

/**
 * 需要执行的任务
 * @author lhy
 *
 */
public class MyJob implements Job {


    @Override
    //把要执行的操作，写在execute方法中
    public void execute(JobExecutionContext arg0) throws JobExecutionException {

        WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
        ServletContext servletContext = webApplicationContext.getServletContext();
        ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);

        DictService dictService = (DictService) applicationContext.getBean("DictService");
        CacheUtil.ajaxJson.setResult(dictService.getProvinceCityHospitalList().getResult());







        System.out.println("测试Quartz"+new Date()+"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");



    }
}
